package org.koyabr.webx.demo.danmaku.web.user.module.action;

import static org.koyabr.webx.demo.danmaku.web.common.DanmakuConstant.*;

import com.alibaba.citrus.service.form.Group;
import com.alibaba.citrus.turbine.Navigator;
import com.alibaba.citrus.turbine.dataresolver.FormGroup;

import org.koyabr.webx.demo.danmaku.biz.UserManager;
import org.koyabr.webx.demo.danmaku.dal.dataobjs.User;
import org.koyabr.webx.demo.danmaku.web.common.DanmakuUser;
import org.springframework.beans.factory.annotation.Autowired;

public class ProfileAction{
	
    @Autowired
    private UserManager userManager;

    public void doUpdate(@FormGroup("profile") Group profile, Navigator nav) throws Exception {
        User user = new User();

        user.setUsername(DanmakuUser.getCurrentUser().getUsername());

        profile.setProperties(user);

        userManager.update(user);

        nav.redirectTo(DANMAKU_PROFILE_LINK);
    }
    
}